<!DOCTYPE html>
<html lang="zh">
<head>
    <#--    <meta charset="utf-8">-->
    <#--    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>-->
    <title>个人信息 - 后台管理系统模板</title>
    <#--    <link rel="icon" href="favicon.ico" type="image/ico">-->
    <#--    <meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">-->
    <#--    <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">-->
    <#--    <meta name="author" content="yinqi">-->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <#include "../../resource.ftl"/>
</head>

<body>
<div class="container-fluid p-t-15">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">

                    <div class="edit-avatar">
                        <img src="images/users/avatar.jpg" alt="..." class="img-avatar">
                        <div class="avatar-divider"></div>
                        <div class="edit-avatar-content">
                            <button class="btn btn-default">修改头像</button>
                            <p class="m-0">选择一张你喜欢的图片，裁剪后会自动生成264x264大小，上传图片大小不能超过2M。</p>
                        </div>
                    </div>
                    <hr>
                    <form id="defaultForm" method="post" class="site-form">
                        <div class="form-group">
                            <input type="hidden" class="form-control" name="id" id="id"
                                   value="${(model.id)?c}" readonly
                            />
                        </div>
                        <div class="form-group">
                            <label for="username">用户编号</label>
                            <input type="text" class="form-control" name="userId" id="userId"
                                   value="${(model.userId)!""}" readonly
                            />
                        </div>
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" name="username" id="username"
                                   value="${(model.username)!""}" readonly
                            />
                        </div>
                        <div class="form-group">
                            <label for="realName">真实名称</label>
                            <input type="text" class="form-control" name="realName" id="realName" placeholder="输入您的真实名称"
                                   value="${(model.realName)!""}">
                        </div>
                        <div class="form-group">
                            <label for="email">邮箱</label>
                            <input type="email" class="form-control" name="email" id="email"
                                   aria-describedby="emailHelp" placeholder="请输入正确的邮箱地址" value="${(model.email)!""}">
                        </div>
                        <div class="form-group">
                            <label for="remark">简介</label>
                            <textarea class="form-control" name="remark" id="remark" rows="3"></textarea>
                        </div>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </form>

                </div>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
<script type="text/javascript">
    (function ($) {
        $.fn.serializeFormJSON = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };
    })(jQuery);

    $('form').submit(function (e) {
        e.preventDefault();
        // var data = $('#defaultForm').serialize(); // 类似get的url拼参数方式，需要转换json
        var data = $(this).serializeFormJSON();
        console.log(data);

        $.ajax({
            type: "POST",
            url: "/sysuser/update",
            cache: false,
            data: JSON.stringify(data),
            dataType: "json",
            contentType: 'application/json;charset=utf-8',
            success: function (data) {
                if (data.code == "0") {
                    // 正确的其他处理...
                    layer.msg(data.msg, {icon: 6});
                } else {
                    // 错误的其他处理...
                    layer.msg(data.msg, {icon: 6});
                }
            },
            error: function (E) {
                console.log(E);
                layer.msg('提交系统失败，请稍后再试', {icon: 6});
            }
        });
    });

    // $(document).ready(function() {

    // });

</script>


</body>
</html>